## BCH codes. Construction and examples

from PyM import *
# 
# def BCH_Code(alpha,d,l=1,K=''):
#     n = order(alpha)
#     h = geometric_series(alpha**l,n)
#     a = geometric_series(alpha, n)
#     show(K_(alpha), base(K_(alpha)))
#     return AC(h,a,d-1,K)
# # alias    
# BCH = BCH_Code

u = 1>>Zn(17)
alpha = 7*u
d = 7
l = 3

C = BCH(alpha,d,l)

H = H_(C)

show( rank(H), order(alpha))

show( shape(H))

# Generating matrix
G = left_kernel(transpose(H))

show( shape(G))

# Verifying the control condition
show( G * transpose(H))

# The minimum distance, which is >= 7 by the BCH bound,
# is actually 7

show( wt(G[0]))